"""
随机生成一个131开头的手机号
"""
import random
from common.handle_db import db
def random_phone():
    while True:
        phone = "131"
        for i in range(8):
            j = random.randint(0,9)
            phone += str(j)
            # 判断手机号是否已注册，如果注册需要重新生成，没有注册直接返回
        sql = "select * from futureloan.member where mobile_phone = {}".format(phone)
        res = db.find_data(sql)
        if not res:
            return(phone)

phone = random_phone()
print(phone)
